<?php
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
MYDCONN();
$GLOBALS['MYT']=$GLOBALS['MYD'];
	if(isset($_GET['id'])) { $_POST['Provider'] = $_GET['id'];}
	if(!isset($_POST['Provider'])) { $_POST['Provider'] = 0; }
	mn_field('button','ED','AddProvider','','','','','add" onclick="
	if (document.edtCdcInvoice.CODE.value<1) {
		alert(\'Indique uma conta\');
	} else {
		idwindow(\'Novo Fornecedor\',\'winprop\',\'winprop\',\'Modules/CentrodeCustos/obj.php?CODE=\'+document.edtCdcInvoice.CODE.value+\'&FormProvider=T\',300,200);
	}');

	if (!isset($_POST['CODE'])){$_POST['CODE']=0;}

	mn_field('select','ED','Provider',$_POST['Provider'],"SELECT 
						ccenter_providers.ref AS ID, 
						ccenter_providers.name AS NAME,
						ccenter_providers.Observations
	  			FROM ccenter_providerscodes
				INNER JOIN ccenter_providers ON ccenter_providers.ref = ccenter_providerscodes.RefProvider
				WHERE ccenter_providerscodes.CODE = {$_POST['CODE']}
				AND ccenter_providers.Status = 1
				ORDER BY name ASC",' ','','" onchange="
	document.edtCdcInvoice.action=\'Modules/CentrodeCustos/Lib/sel_contract.php\';
	subform(\'edtCdcInvoice\',\'ContractDiv\');');